package com.hpin.mlxteacher.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.bean.SingleSignResule;

import java.util.List;

/**
 * Created by Aaron on 2015/7/28.
 */
public class HistoryAdapter extends BaseAdapter {

    private Context ctx;
    private List<SingleSignResule.SignDay> signDayList;

    public HistoryAdapter(Context ctx, List<SingleSignResule.SignDay> signDayList) {
        this.ctx = ctx;
        this.signDayList = signDayList;
    }

    @Override
    public int getCount() {
        return signDayList.size();
    }

    public void setSignDayList(List<SingleSignResule.SignDay> signDayList) {
        this.signDayList = signDayList;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder=null;

        if (convertView == null) {

            convertView = View.inflate(ctx, R.layout.item_history, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_date_day = (TextView) convertView.findViewById(R.id.tv_date_day);

            viewHolder.cb_am = (ImageView) convertView.findViewById(R.id.cb_am);
            viewHolder.cb_noon = (ImageView) convertView.findViewById(R.id.cb_noon);
            viewHolder.cb_pm = (ImageView) convertView.findViewById(R.id.cb_pm);

            convertView.setTag(viewHolder);

        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }

        viewHolder.tv_date_day.setText(signDayList.get(position).signDate);

        viewHolder.cb_am.setSelected(signDayList.get(position).signM == 1);

        viewHolder.cb_am.setSelected(signDayList.get(position).signM == 1);//

        viewHolder.cb_noon.setSelected(signDayList.get(position).signA == 1);

        viewHolder.cb_pm.setSelected(signDayList.get(position).signN == 1);

        return convertView;
    }

    private class ViewHolder {

        private TextView tv_date_day;
        private ImageView cb_am;
        private ImageView cb_noon;
        private ImageView cb_pm;
    }
}
